﻿# Paths
$packFolder = (Get-Item -Path "./" -Verbose).FullName
#$packFolder="D:\Projects\PlatformSharp\nupkg"
Write-Host $packFolder


$slnPath = Join-Path $packFolder "..\"
$srcPath = Join-Path $slnPath ""

Write-Host $slnPath


# List of projects
$projects = @(
    "Sharp.Infrastructure.AutoMapper",
    "Sharp.Infrastructure",
	"Sharp.Application"
)
$folders=@("平台","平台","平台")

# Rebuild solution
Set-Location $slnPath
& dotnet restore


# Copy all nuget packages to the pack folder
for($i=0;$i -lt $projects.Length;$i++)
{
    $project = $projects[$i]

    $projectFolder = Join-Path $slnPath $folders[$i]
    $projectFolder = Join-Path $projectFolder $project
    Write-Host "C"+ $projectFolder

    # Create nuget pack
    Set-Location $projectFolder
    #dotnet msbuild /p:Configuration=Release /p:SourceLinkCreate=true
    #dotnet msbuild /t:pack /p:Configuration=Release /p:SourceLinkCreate=true
    dotnet pack -c Release

    # Copy nuget package
    $projectPackPath = Join-Path $projectFolder ("/bin/Release/" + $project + ".*.nupkg")
    Move-Item $projectPackPath $packFolder -Force
}


# Go back to the pack folder
Set-Location $packFolder